<template>
  <div>
    <!-- 数据统计 -->
    <el-row :gutter="20">
      <el-col :span="6" v-for="(item, index) in counts" :key="index">
        <el-card class="box-card" shadow="hover">
          <div class="d-flex align-items-center">
            <i class="h4 text-white mb-0" :class="[item.icon,item.color]"></i>
            <div class="ml-3">
              <h4 class="mb-1">{{item.num}}</h4>
              <div class="text-muted small">{{item.desc}}</div>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 店铺数据和统计图 -->
    <el-row :gutter="20" class="mt-3">
      <el-col
        :span="12"
        style="display: flex; flex-direction: column;  justify-content: space-between; height: 370px;"
      >
        <el-card class="box-card" v-for="(item,index) in tips" :key="index">
          <div slot="header" class="clearfix">
            <span>{{item.title}}</span>
            <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>
          </div>
          <div class="row">
            <div
              :class="item.lists.length|fnName"
              v-for="(item2,index2) in item.lists"
              :key="index2"
            >
              <button class="w-100 btn btn-light">
                <h4 class="mb-1">{{item2.num}}</h4>
                <div class="text-muted small">{{item2.value}}</div>
              </button>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="box-card" style="height: 370px;">
          <div slot="header" class="clearfix">
            <span>交易提示</span>
            <el-button style="float: right; padding: 3px 0" type="text">操作按钮</el-button>
          </div>
          <div ref="myEchart" style="width: 100%; height: 270px;"></div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 销售统计和单品销售排名 -->
    <el-row :gutter="20" class="mt-3" style="margin-bottom:60px;">
      <el-col :span="12">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>销售情况统计</span>
            <el-button style="float: right; padding: 3px 0" type="text">按周期统计商家店铺的订单和订单金额</el-button>
          </div>

          <div class="media align-items-center border mt-1">
            <span class="py-4 px-3 bg-light border-right">昨日销量</span>

            <div class="media-body">
              <div class="border-bottom pl-3">
                <span>订单量（件）</span>
                12
              </div>

              <div class="pl-3">
                <span>订单量（件）</span>
                12
              </div>
            </div>
          </div>

          <div class="media align-items-center border my-4">
            <span class="py-4 px-3 bg-light border-right">昨日销量</span>

            <div class="media-body">
              <div class="border-bottom pl-3">
                <span>订单量（件）</span>
                12
              </div>
              <div class="pl-3">
                <span>订单量（件）</span>
                12
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="12">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>单品销售排名</span>
            <el-button style="float: right; padding: 3px 0" type="text">按周期统计商家店铺的订单和订单金额</el-button>
          </div>
          <el-table :data="tableData" height="200" border style="width: 100%">
            <el-table-column type="index" label="#" width="50"></el-table-column>
            <el-table-column prop="name" label="商品信息"></el-table-column>
            <el-table-column prop="num" label="商品销量" width="50"></el-table-column>
          </el-table>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import echarts from "echarts";
export default {
  data() {
    return {
      tableData: [
        {
          name: "洗衣液体",
          num: "200",
        },
        {
          name: "洗衣液体",
          num: "200",
        },
        {
          name: "洗衣液体",
          num: "200",
        },
        {
          name: "洗衣液体",
          num: "200",
        },
        {
          name: "洗衣液体",
          num: "200",
        },
      ],

      tips: [
        {
          title: "商铺及商品提示",
          desc: "需要关注的店铺信息及待办处理事项",
          lists: [
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "68",
              value: "出售中",
            },
          ],
        },
        {
          title: "商铺及商品提示",
          desc: "需要关注的店铺信息及待办处理事项",
          lists: [
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "64",
              value: "出售中",
            },
            {
              num: "68",
              value: "出售中",
            },
            {
              num: "68",
              value: "出售中",
            },
            {
              num: "68",
              value: "出售中",
            },
          ],
        },
      ],

      counts: [
        {
          icon: "el-icon-user-solid",
          num: "3",
          desc: "关注人数（个）",
          color: "bg-primary",
        },
        {
          icon: "el-icon-data-line",
          num: "120",
          desc: "订单总数（笔）",
          color: "bg-info",
        },
        {
          icon: "el-icon-s-order",
          num: "4183.80",
          desc: "今日订单总金额（元）",
          color: "bg-danger",
        },
        {
          icon: "el-icon-s-data",
          num: "100",
          desc: "本月销量（笔）",
          color: "bg-warning",
        },
      ],

      option: {
        title: {
          text: "",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data: ["邮件营销", "联盟广告", "视频广告", "直接访问", "搜索引擎"],
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: ["周一", "周二", "周三", "周四", "周五", "周六", "周日"],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "邮件营销",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "联盟广告",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "视频广告",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [150, 232, 201, 154, 190, 330, 410],
          },
          {
            name: "直接访问",
            type: "line",
            stack: "总量",
            areaStyle: {},
            data: [320, 332, 301, 334, 390, 330, 320],
          },
          {
            name: "搜索引擎",
            type: "line",
            stack: "总量",
            label: {
              normal: {
                show: true,
                position: "top",
              },
            },
            areaStyle: {},
            data: [820, 932, 901, 934, 1290, 1330, 1320],
          },
        ],
      },
    };
  },

  filters: {
    fnName(value) {
      return "col-" + 12 / value;
    },
  },
  mounted() {
    this.drawLine();
  },

  methods: {
    drawLine() {
      //初始化Echarts
      let myEchart = echarts.init(this.$refs.myEchart);
      console.log(myEchart);

      //配置参数
      myEchart.setOption(this.option);
    },
  },
};
</script>

<style>
.small {
  font-size: 12px;
}
</style>
